<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>背景图像的尺寸</title>

        <style type="text/css">
            h3 { text-align: center ; }

            .wrapper {
                width: 800px ;
                height: 400px ;
                background-color: yellow ;
                background-image: url( liuyifei.jpg ); /* 背景图像 */
                background-repeat: no-repeat ; /* 不重复 */
                background-position: center ; /* 上下居中、左右居中*/
                border: 1px solid blue ;
                margin: 30px auto ;
            }

            .first { background-size: auto ; }

            .second { background-size: contain ; }

            .third { background-size: contain ; width: 300px ; }

            .fourth { background-size: cover ; }

            .fifth { background-size: 25% 100% ; }

        </style>
    </head>
    <body>

        <h3>背景图像的尺寸</h3>

        <div class="wrapper first"></div>

        <div class="wrapper second"></div>

        <div class="wrapper third"></div>

        <div class="wrapper fourth"></div>

        <div class="wrapper fifth"></div>
        
    </body>
</html>